#include <iostream>
#include <cstdio>

using namespace std;

#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))

inline long long ckjread()
{
	long long s=0,w=1,ch=getchar();
	while(ch<'0'||ch>'9') ch=='-'?w=-1,ch=getchar():ch=getchar();
	while(ch>='0'&&ch<='9') s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
	return s*w;
}

void jynwriten(long long x)
{
	x>9?jynwriten(x/10),putchar(x%10|48):putchar(x|48);
}

long long n,l,r;

int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	n=ckjread();
	l=ckjread();
	r=ckjread();
	long long ckj=l%n;
	long long jyn=r-l;
	jynwriten(min(n-1,ckj+jyn));
	putchar('\n');
	return 0;
}
